Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
JOOQ "IN" Query throws null pointer exception

When we try to fetch data with Null values

field(TABLE_NAME.COLUMN_NAME.in(null))

with IN clause getting null pointer exception.

Maybe because of this.

  @Override
    public final Condition in(Collection<?> values) {
        Field<?>[] fields = new Field[values.size()];

        Iterator<?> it = values.iterator();
        for (int i = 0; it.hasNext(); i++)
            fields[i] = Tools.field(it.next(), this);

        return in(fields);
    }

In the database, we can provide null in IN clause.

There is an existing "won't fix" issue in jooq https://github.com/jOOQ/jOOQ/issues/3867

There are some alternatives:

  • check null before IN(Cant do in my case its a really big select statement)

So if I want to make this possible is there any other workaround.

PS: On a similar note "eq" works perfectly fine:

@Override
    public final Condition equal(Field<T> field) {
        return compare(EQUALS, nullSafe(field, getDataType()));
    }

Edit: 'field(TABLE_NAME.COLUMN_NAME.in(null))' here null is a collection.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Your example code doesn't compile:

TABLE_NAME.COLUMN_NAME.in(null)

There are 5 overloads of this in() method in jOOQ 3.14, and as such, you cannot pass the null literal to the in() method. Your real client code may be using a local variable like this:

Collection<?> collection = null;
TABLE_NAME.COLUMN_NAME.in(collection)

There might be a case for when this should behave the same as passing an empty collection, such as Collections.emptyList(), but this isn't what you seem to want. You probably want to pass actual null values inside of that collection, which you can do:

TABLE_NAME.COLUMN_NAME.in(1, null, 2)

But why would you do it? SQL implements three valued logic, meaning that NULL values have no effect in IN predicates, while they have an unintuitive, hardly desired effect in NOT IN predicates (the entire predicate becomes NULL)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda